#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from VectorTestSequence import VectorVsetvlTestSequence
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU
from gpgpu.Utils import LoadGPR64


#  This test verifies the VSETVL instruction sets the vl and vtype registers
#  as expected.
class MainSequence(VectorVsetvlTestSequence):
    def __init__(self, aGenThread, aName=None):
        super().__init__(aGenThread, aName)

        self._mInstrList = ("VSETVL##CALM",)

    # Return a list of test instructions to randomly choose from.
    def _getInstructionList(self):
        return self._mInstrList

    # Generate parameters to be passed to Sequence.genInstruction() and load
    # register operands.
    def _generateInstructionParameters(self):
        instr_params = {}

        load_gpr64_seq = LoadGPR64(self.genThread)
        (avl_reg_index, vtype_reg_index) = self.getRandomGPRs(2, exclude="0")
        load_gpr64_seq.load(avl_reg_index, self.mAvl)
        instr_params["rs1"] = avl_reg_index
        load_gpr64_seq.load(vtype_reg_index, self.mVtype)
        instr_params["rs2"] = vtype_reg_index

        return instr_params


MainSequenceClass = MainSequence
GenThreadClass = GenThreadGPGPU
EnvClass = EnvGPGPU
